package com.app.service.impl;


import com.app.mapper.SchoolMapper;
import com.app.mapper.TrainTypeConfigMapper;
import com.app.model.ExpertModel;
import com.app.model.SchoolModel;
import com.app.model.TrainEnrollModel;
import com.app.model.TrainTypeConfigModel;
import com.app.service.SchoolService;
import com.app.service.TrainTypeConfigService;
import com.app.util.StringTool;
import com.app.vo.SchoolVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TrainTypeConfigServiceImpl implements TrainTypeConfigService {

    @Resource
    private TrainTypeConfigMapper trainTypeConfigMapper;


    @Override
    public List<TrainTypeConfigModel> getListById(Integer fatherId) {
        QueryWrapper<TrainTypeConfigModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select().eq("train_id", fatherId);
        List<TrainTypeConfigModel> list = trainTypeConfigMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public int insert(TrainTypeConfigModel model) {
        return trainTypeConfigMapper.insert(model);
    }

    @Override
    public void delete(Integer id) {
        QueryWrapper<TrainTypeConfigModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select().eq("train_id", id);
        trainTypeConfigMapper.delete(queryWrapper);
    }

    @Override
    public List<TrainTypeConfigModel> getListByTrainId(Integer trainId, Integer typeId) {
        QueryWrapper<TrainTypeConfigModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select().eq("train_id", trainId);
        queryWrapper.select().eq("type", typeId);
        List<TrainTypeConfigModel> list = trainTypeConfigMapper.selectList(queryWrapper);
        return list;
    }
}
